package com.cdream.basic.algorithm.leetcode.array;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author cdream
 * @date 10/30/21
 */
public class Question260 {
    public int[] singleNumber(int[] nums) {
        HashMap<Integer,Integer> map = new HashMap<>();
        for(int num: nums){
            map.merge(num, 1,(a,b)->a+b);
        }
        List<Integer> res = new ArrayList<Integer>();

        map.forEach((k,v)-> {
            if(v==1){
                res.add(k);
            }
        });
        return res.stream().mapToInt(a-> a).toArray();
    }
}
